<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Document</title></head><script type="text/javascript">Date.prototype.addDays = function(days){ var result = new Date(this.valueOf()); result.setDate(this.getDate() days); return result;} var EndTime= new Date('2016/7/10 20:30:00'); //截止时间 EndTime=new Date().addDays(12); function getRTime(){ var NowTime = new Date(); var t =EndTime.getTime() - NowTime.getTime(); /*var d=Math.floor(t/1000/60/60/24); t-=d*(1000*60*60*24); var h=Math.floor(t/1000/60/60); t-=h*60*60*1000; var m=Math.floor(t/1000/60); t-=m*60*1000; var s=Math.floor(t/1000);*/ var d=Math.floor(t/1000/60/60/24); var h=Math.floor(t/1000/60/60%24); var m=Math.floor(t/1000/60%60); var s=Math.floor(t/1000%60); document.getElementById("t_d").innerHTML = d; document.getElementById("t_h").innerHTML = h; document.getElementById("t_m").innerHTML = m; document.getElementById("t_s").innerHTML = s; } setInterval(getRTime,1000); </script><body><div> <span id="t_d" style="font-size: 30px; color: #c01710; margin: 0px 10px;">00</span>天 <span id="t_h" style="font-size: 30px; color: #c01710; margin: 0px 10px;">00</span>时 <span id="t_m" style="font-size: 30px; color: #c01710; margin: 0px 10px;">00</span>分 <span id="t_s" style="font-size: 30px; color: #c01710; margin: 0px 10px;">00</span>秒</div></body></html>
评论